package com.zy.demo;

import com.zy.constant.MqConstant;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;

public class BatchTest {


    @Test
    public void batchTest() throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("batchTest-producer-group");

        producer.setNamesrvAddr(MqConstant.NAMESRV_ADDR);

        producer.start();

        List<Message> list = Arrays.asList(
                new Message("batchTopic","1".getBytes()),
                new Message("batchTopic","2".getBytes()),
                new Message("batchTopic","3".getBytes())
        );

        producer.send(list);

        producer.shutdown();

    }

}
